<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
      layout:decorate="~{admin/layout}">
<!-- begin #content -->
<body>
<div class="content-wrap" layout:fragment="content">
    <link rel="stylesheet"  th:href="@{/css/default.css}" />
    <link rel="stylesheet"  th:href="@{/css/component.css}" />
    <style>
        .jianju{
            margin:5px;
        }
        .buttoon-height{
            height: 45px;
        }
    </style>
    <main id="content" class="content" role="main">
        <ol class="breadcrumb">
            <li>苗圃总览</li>
            <li class="active">地块增减</li>
        </ol>
        <div class="main">
            <ul class="cbp_tmtimeline">
                <li th:each="areaLocation:${areaLocation}">
                    <time class="cbp_tmtime">
                    </time>
                    <div class="caname cbp_tmicon" th:text="${areaLocation.serialNumber}" th:value="${areaLocation.areaLocation_id}"></div>
                    <div class="cbp_tml=dabel">
                        <p>
                            <a class="jianju btn btn-success width-100 mb-xs buttoon-height"role="button"
                                     th:each="landMass:${areaLocation.landMasses}"
                                 th:href="@{/admin/landMass/updateLandMass(landMass_id=${landMass.landMass_id})}">
                                <span th:text="${landMass.areaLocation.serialNumber}"></span>-<span th:text="${landMass.serialNumber}"></span>
                            </a>
                            <button style="background-color: #dd5826;border-color: #dd5826;width: 45px;" class="jianju btn btn-success width-100 mb-xs buttoon-height"role="button">
                                <a style="color: #ffffff" title="新增地块"
                                   class="glyphicon glyphicon-plus" th:href="@{/admin/landMass/addLandMass(areaLocation_id=${areaLocation.areaLocation_id})}"></a>
                            </button>
                            <button style="background-color: #dd5826;border-color: #dd5826;width: 45px;" class="jianju btn btn-success width-100 mb-xs buttoon-height"role="button">

                                <a style="color: #ffffff" title="删除地块"
                                   class="glyphicon glyphicon-minus" th:href="@{/admin/areaLocation/delete(areaLocation_id=${areaLocation.areaLocation_id})}"></a>
                            </button>
                        </p>
                    </div>
                </li>
                <li>
                    <time class="cbp_tmtime">
                    </time>
                    <a th:href="@{/admin/areaLocation/update}" title="新增地块" class="cbp_tmicon glyphicon glyphicon-plus"></a>
                </li>
            </ul>
            <script >
                $(function() {
                    $(".caname").click(function() {
                        var td = $(this);
                        var id=td.attr("value");
                        var txt = td.text();
                        var input = $("<input style='background: transparent;border: none;outline: none' type='text'value='" + txt + "'/>");
                        td.html(input);
                        input.click(function() { return false; });
                        input.trigger("focus");
                        input.blur(function() {
                            var newtxt = $(this).val();
                            if (newtxt != txt) {
                                td.html(newtxt);
                                $.ajax({
                                    url: "/admin/areaLocation/upname?id="+id+'&values='+newtxt,
                                    type: 'POST',
                                    async: false,
                                    success: function (data) {
                                        location.reload();
                                    },
                                });
                            }
                            else
                            {
                                td.html(newtxt);
                            }
                        });
                    });
                });

            </script>
        </div>
    </main>
</div>
</body>
</html>
